<?xml version="1.0"?>

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html" xmlns:aui="http://liferay.com/faces/aui"
                xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun.com/jsf/facelets">
  <h:head></h:head>

  <h2>Lägg till ett dokumentflöde</h2>

  <p:messages id="error-messages"/>

    <div class="container-fluid">
        <div class="row-fluid">
            <div class="span4 first">
                <h:outputLabel value="Namnge dokumentpubliceringen" />
                <h:inputText id="title" name="title" value="#{iFeedModelBean.name}" />
            </div>
            <div class="span4">
                <h:outputLabel value="Beskriv syftet med publiceringen "/>
                <h:inputTextarea autoResize="false" value="#{iFeedModelBean.description}" maxlength="1000" />
            </div>
            <div class="span4 last">
                <h:panelGroup id="addIfeedDepartmentAndGroup" layout="block">
                    <h:outputLabel value="Välj förvaltning" for="selectGovernance"/>

                    <h:selectOneMenu converter="departmentConverter"
                                     update="addIfeedDepartmentAndGroup"
                                     ajax="true"
                                     id="selectGovernance"
                                     immediate="true"
                                     value="#{iFeedModelBean.department}">
                        <f:selectItem itemLabel="-" itemValue="#{null}"/>
                        <f:selectItems value="#{app.getVgrDepartments()}"
                                       var="i" itemLabel="#{i.name}" itemValue="#{i}"/>
                        <f:ajax render="addIfeedDepartmentAndGroup" />
                    </h:selectOneMenu>

                    <h:outputLabel value="Välj grupptillhörighet"/>

                    <h:selectOneMenu converter="groupConverter"
                                     update="addIfeedDepartmentAndGroup"
                                     ajax="true"
                                     rendered="#{iFeedModelBean.department != null}"
                                     value="#{iFeedModelBean.group}">
                        <f:selectItem itemLabel="-" itemValue="#{null}"/>
                        <f:selectItems value="#{iFeedModelBean.department.vgrGroups}"
                                       var="i" itemLabel="#{i.name}" itemValue="#{i}"/>
                        <f:ajax render="addIfeedDepartmentAndGroup" />
                    </h:selectOneMenu>

                    <h:selectOneMenu converter="groupConverter"
                                     update="addIfeedDepartmentAndGroup"
                                     disabled="true"
                                     rendered="#{iFeedModelBean.department == null}">
                        <f:selectItem itemLabel="-" itemValue="#{null}"/>
                    </h:selectOneMenu>


                </h:panelGroup>
            </div>
        </div>
    </div>




  <aui:button-row>
      <p:commandLink styleClass="rp-link-button secondary"
                     actionListener="#{editIFeedBackingBean.goBackToIFeedList}" value="Avbryt" update=":ifeed_view"
                     ajax="false" async="true"/>

      <p:commandLink styleClass="rp-link-button rp-link-button-alt" value="Spara och fortsätt"
                     update=":ifeed_view" actionListener="#{editIFeedBackingBean.addIFeed}" ajax="false" async="true"/>

  </aui:button-row>

</ui:composition>